//
//  MainViewController.m
//  FruitsAndHealthy
//
//  Created by appying_wxj on 14/11/10.
//  Copyright (c) 2014年 appying_wxj. All rights reserved.
//

#import "MainViewController.h"
#import "FruitsViewController.h"// 水果的功效
#import "AdviceViewController.h"// 食用锦囊
#import "TabooViewController.h"// 食用禁忌
#import "ChooseStorageViewController.h"// 选购和存储


@interface MainViewController ()

@end

@implementation MainViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)viewWillAppear:(BOOL)animated{
    [self.navigationController setNavigationBarHidden:YES];// 隐藏系统的导航条
    [super viewWillAppear:animated];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self.navigationController setNavigationBarHidden:YES];// 隐藏系统的导航条
    
    
    
    // 改变导航条字体颜色和大小
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"FZZZHUNHJW--GB1-0" size:20], NSFontAttributeName,nil]];

    self.navigationController.navigationBar.tintColor = [UIColor redColor];
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:0.76 green:0.85 blue:0.02 alpha:1]];
    [self initUI];
}

// 创建控件
-(void)initUI{
    
    _mainImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height)];
    _mainImage.image = [UIImage imageNamed:@"image_main@2x"];
    _mainImage.userInteractionEnabled = YES;
    [self.view addSubview:_mainImage];
    
    // 测试收藏按钮
    UIButton *collecBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    collecBtn.backgroundColor = [UIColor clearColor];
    collecBtn.frame = CGRectMake(kScreen_Width-90, 20, 70, 85);
    [collecBtn addTarget:self action:@selector(collecButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [_mainImage addSubview:collecBtn];
    
    
    // 水果的功效
    UIButton *healthyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    healthyBtn.backgroundColor = [UIColor clearColor];
    [healthyBtn addTarget:self action:@selector(healthyButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    // 食用锦囊
    UIButton *effectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    effectBtn.backgroundColor = [UIColor clearColor];
    [effectBtn addTarget:self action:@selector(effectButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    // 食用禁忌
    UIButton *tabooBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    tabooBtn.backgroundColor = [UIColor clearColor];
    [tabooBtn addTarget:self action:@selector(tabooButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    // 选购存储
    UIButton *miscellaneousBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    miscellaneousBtn.backgroundColor = [UIColor clearColor];
    [miscellaneousBtn addTarget:self action:@selector(miscellaneousButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    if (kScreen_Height == 480) {
        healthyBtn.frame = CGRectMake(60, 96, 200, 40);
        effectBtn.frame = CGRectMake(60, 115+30, 200, 40);
        tabooBtn.frame = CGRectMake(60, 112+20+60, 200, 40);
        miscellaneousBtn.frame = CGRectMake(60, 111+130, 200, 40);
    }else{
        healthyBtn.frame = CGRectMake(60, 113, 200, 50);
        effectBtn.frame = CGRectMake(60, 112+50+9, 200, 50);
        tabooBtn.frame = CGRectMake(60, 112+45+70, 200, 50);
        miscellaneousBtn.frame = CGRectMake(60, 112+42+130, 200, 50);
    }
    
    [_mainImage addSubview:healthyBtn];
    [_mainImage addSubview:effectBtn];
    [_mainImage addSubview:tabooBtn];
    [_mainImage addSubview:miscellaneousBtn];
    
    
    
    
}
#pragma mark——————按钮的点击时间——————
// 水果功效 按钮的点击事件
-(void)healthyButtonClick:(UIButton *)sender{
    FruitsViewController *fruits = [[FruitsViewController alloc] init];
    fruits.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

    [self presentViewController:fruits animated:YES completion:nil];
}
// 食用锦囊 按钮的点击时间
-(void)effectButtonClick:(UIButton *)sender{
    AdviceViewController *advice = [[AdviceViewController alloc] init];
    advice.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    
    [self presentViewController:advice animated:YES completion:nil];
}
// 食用禁忌 按钮的点击事件
-(void)tabooButtonClick:(UIButton *)sender{
    TabooViewController *taboo = [[TabooViewController alloc] init];
    taboo.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    
    [self presentViewController:taboo animated:YES completion:nil];
}
// 选购和存储 按钮的点击事件
-(void)miscellaneousButtonClick:(UIButton *)sender{
    ChooseStorageViewController *choose = [[ChooseStorageViewController alloc] init];
    choose.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    
    [self presentViewController:choose animated:YES completion:nil];
}
// 收藏按钮的点击事件
-(void)collecButtonClick:(UIButton *)sender{
    CollectViewController *collect = [[CollectViewController alloc] init];
    collect.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentViewController:collect animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
